package com.itheima.reggie.mapper;


import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Insert("INSERT INTO category (`id`, `type`, `name`, `sort`, `create_time`, `update_time`, `create_user`, `update_user`) VALUES (null, #{type}, #{name}, #{sort}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void insertNewCategory(Category category);

    @Select("select * from category order by sort")
    List<Category> selectAllOrderBySort();

    @Delete("delete from category where id = #{categoryId}")
    void deleteById(String categoryId);

    @Update("update category set name = #{name},sort = #{sort},update_time = #{updateTime},update_user = #{updateUser} where id = #{id}")
    void updateById(Category category);

    @Select("select * from category where type = #{type}")
    List<Category> selectByType(Integer type);

    @Select("select * from category")
    List<Category> selectAll();
}
